<template>
  <div class="header-container">
    <div class="header-items-container">
      <div class="header-logo" @click="gotoHome">随手递</div>
      <div class="header-item">首页</div>
      <div class="header-item" @click="gotoUserOrder">我的订单</div>
      <div class="header-user">
        <el-dropdown @command="handleCommand">
          <span style="color: #ffffff;">
            <i class="far fa-user"></i>
            &nbsp;李爽爽
            <i class="el-icon-arrow-down"></i>
          </span>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item command="gotoUserCenter">个人中心</el-dropdown-item>
            <el-dropdown-item command="gotoUserAddress">我的地址</el-dropdown-item>
            <el-dropdown-item command="gotoUserWallet">我的钱包</el-dropdown-item>
            <el-dropdown-item command="logout" divided>退出</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </div>
    </div>
  </div>
</template>
<script>
// import { mapGetters, mapActions } from 'vuex'
import { ROUTENAME } from 'services/constConfig.js'

export default {
  methods: {
    gotoHome() {
      this.$router.push({ path: ROUTENAME.HOME })
    },
    logout() {
      this.$router.push({ path: ROUTENAME.HOME })
    },
    gotoUserOrder() {
      this.$router.push({ path: ROUTENAME.USER_ORDER })
    },
    handleCommand(command) {
      if (command === 'logout') {
        // this.setNowUser(null)
        this.logout()
      }
      if (command === 'gotoUserCenter') {
        // if (this.nowUser.role === 1) {
        this.$router.push({ path: ROUTENAME.USER })
      }
      if (command === 'gotoUserAddress') {
        // if (this.nowUser.role === 1) {
        this.$router.push({ path: ROUTENAME.USER_ADDRESS })
      }
      if (command === 'gotoUserWallet') {
        // if (this.nowUser.role === 1) {
        this.$router.push({ path: ROUTENAME.USER_WALLET })
      }
    }
  }
}
</script>
<style scoped>
.header-container {
  width: 100%;
  height: 60px;
  background-color: #1e89e0;
}
.header-items-container {
  width: 1200px;
  height: 60px;
  /* background-color: red; */
  margin-left: auto;
  margin-right: auto;
}
.header-logo {
  height: 60px;
  line-height: 60px;
  float: left;
  margin-left: 10px;
  margin-right: 30px;
  font-size: 26px;
  color: #ffffff;
}
.header-item {
  height: 60px;
  line-height: 60px;
  float: left;
  font-size: 16px;
  color: #ffffff;
  padding-left: 30px;
  padding-right: 30px;
}
.header-item:hover {
  cursor: pointer;
  background-color: #006bc7;
}
.header-logo:hover {
  cursor: pointer;
}
.header-user {
  float: right;
  height: 60px;
  line-height: 60px;
  font-size: 20px;
  color: #ffffff;
}
.header-user:hover {
  cursor: pointer;
}
</style>